//
//  Common.m
//  ProjectDemo
//
//  Created by IOS3 on 2018/10/22.
//  Copyright © 2018 IOS3. All rights reserved.
//

#import <Foundation/Foundation.h>


/// DLog 调用NSLog
/// DPrint 调用print, 用于输出NSLog无法输出的长打印
#ifdef DEBUG
#define DLog(fmt, ...) NSLog((@"\n\n\n##########  class: < %s " "(%d) >" "   method: %s \n" fmt), [[NSString stringWithFormat:@"%s", __FILE__].lastPathComponent UTF8String], __LINE__,  __FUNCTION__, ##__VA_ARGS__);
#define DPrint(format, ...) printf("\n\n##########  class: < %s:(%d行) > method: %s \n%s\n", [[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, __PRETTY_FUNCTION__, [[NSString stringWithFormat:(format), ##__VA_ARGS__] UTF8String] );
#else
#define DLog(...);
#define DPrint(...);
#endif


// 当前Xcode支持iOS8及以上
#define SCREEN_WIDTH ([[UIScreen mainScreen] respondsToSelector:@selector(nativeBounds)] ? ([UIScreen mainScreen].nativeBounds.size.width / [UIScreen mainScreen].nativeScale) : [UIScreen mainScreen].bounds.size.width)
#define SCREEN_HEIGHT ([[UIScreen mainScreen] respondsToSelector:@selector(nativeBounds)] ? ([UIScreen mainScreen].nativeBounds.size.height / [UIScreen mainScreen].nativeScale) : [UIScreen mainScreen].bounds.size.height)

// 是不是刘海屏
#define IS_SPECIAL_SHAPE ({\
BOOL flag = NO;\
if (@available(iOS 11.0, *)) {\
UIWindow *mainWindow = [[[UIApplication sharedApplication] delegate] window];\
if (mainWindow.safeAreaInsets.bottom > 0.0) {\
flag = YES;\
}\
}\
flag;\
})

// 状态栏 + 导航栏高度 (正常小标题导航栏)
#define TOP_HEIGHT (IS_SPECIAL_SHAPE ? 88.f : 64.f)



// Color
#define RANDOM_COLOR [UIColor colorWithRed:arc4random_uniform(256)/255.0 green:arc4random_uniform(256)/255.0 blue:arc4random_uniform(256)/255.0 alpha:1.0]
#define RGB(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0]
#define RGBA(r, g, b, a) [UIColor colorWithRed:(r)/255.0 green:(r)/255.0 blue:(r)/255.0 alpha:a]




// BASE URL
#ifdef DEBUG
#define DEFAULT_BASE_URL @"https://www.apiopen.top" 
#else
#define DEFAULT_BASE_URL @""
#endif



